package com.zkadmin.renderer;

import java.util.Set;

import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;

import com.zkadmin.entity.SysRole;

public class UserRoleListRenderer extends BaseRenderer implements ListitemRenderer<SysRole> {
	private Set<SysRole> roles;

	public UserRoleListRenderer(Set<SysRole> roles) {
		this.roles = roles;
	}

	@Override
	public void render(Listitem item, final SysRole role, int index) throws Exception {
		item.setAttribute("roleId", role.getId());
		if (roles.contains(role)) {
			item.setSelected(true);
		}
		createListcell(item).setLabel(role.getRole());
		createListcell(item).setLabel(role.getName());
	}
}
